package fhp.hlhj.giantfold.module

import com.lzy.okgo.model.HttpParams
import fhp.hlhj.giantfold.javaBean.TittleBean
import fhp.hlhj.giantfold.network.UrlApis

/**
 * author: FHP
 * data: on 2018\1\16 0016 11:10
 * E-Mail: 103945089@qq.com
 */
class SpendBuyModule {
    interface SpendBuyListener{
        fun showLoading()
        fun onTittleListener(tittleBean: TittleBean)
        fun onFindGoodsListener(tittleBean: TittleBean)
    }

    /**
     * 获取一级板块
     */
    fun getTittles(params: HttpParams,listener: SpendBuyListener){
        UrlApis.getFirst(params)
                .doOnSubscribe {
                    listener.showLoading()
                }
                .subscribe ({
                    data->
                    listener.onTittleListener(data)
                },{
                    data->
                    data.printStackTrace()
                })
    }
    fun getfindGoods(params: HttpParams,listener: SpendBuyListener){
        UrlApis.getFirst(params)
                .doOnSubscribe {
                    listener.showLoading()
                }
                .subscribe ({
                    data->
                    listener.onFindGoodsListener(data)
                },{
                    data->
                    data.printStackTrace()
                })
    }
}